<!--
 * @description: 
 * @Date: 2023-11-09 11:04:40
 * @example: 
 * @params: 
-->
<template>
  <div class="treeBox">
    <treenode
      v-for="(model, index) in treeData"
      :model="model"
      :key="index"
      :withoutParents="withoutParents"
      :ids="ids"
      :options="treeOptions"
    >
    </treenode>
  </div>
</template>
<script>
/**
 *时间：2018/09/18
 *作者:Summer
 *功能:
 *
 * @参数：
 *
 */
import tree from "./items";

export default {
  name: "Tree",
  model: {
    prop: "ids",
    event: "change",
  },
  props: {
    treeData: {
      type: Array,
      default() {
        return [];
      },
    },
    ids: {
      type: Array,
      default() {
        return [];
      },
    },
    withoutParents: {
      type: Array,
      default() {
        return [];
      },
    },
    options: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {
      defaultOptions: {
        withParents: true,
      },
      treeOptions: {},
    };
  },
  created() {
    this.initOptions();
  },
  mounted() {},
  watch: {},
  methods: {
    // 初始化默认选项
    initOptions() {
      this.treeOptions = { ...this.defaultOptions, ...this.options };
    },
  },
  components: {
    treenode: tree,
  },
};
</script>
<style lang="less" scoped="scoped">
.treeBox {
  // margin-top: 20px;
  // display: inline-block;
  width: 100%;
  // border: 1px solid red;
}
</style>
